import 'package:dustbin_sort/model/news_model_entity.dart';
import 'package:dustbin_sort/util/navigator_util.dart';
import 'package:dustbin_sort/widget/cached_image.dart';
import 'package:dustbin_sort/widget/web_view.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class NewsList extends StatelessWidget
{
	final List<NewsModelResultData> newsModelResult;

  const NewsList({Key key,@required this.newsModelResult}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
			children: <Widget>[
				GestureDetector(
					child: Container(
						color: Colors.white,
						padding: EdgeInsets.fromLTRB(9,7,9,0),
						child: Row(
							children: <Widget>[
								Expanded(
										flex: 1,
										child: Container(
											height: MediaQuery.of(context).size.width/3,
											child: Container(
												child: ClipRRect(
														borderRadius: BorderRadius.circular(9),
														child: new CachedImage(
															imageUrl: newsModelResult[0].thumbnailPicS,
															fit: BoxFit.cover,
														)
												),
												margin: EdgeInsets.all(7),
												decoration: BoxDecoration(
													borderRadius: BorderRadius.circular(7),
													//																color: Colors.grey,
												),
											),
										)
								),
								Expanded(
										flex: 2,
										child: Container(
											height: MediaQuery.of(context).size.width/3,
											child: Container(
												margin: EdgeInsets.all(7),
												decoration: BoxDecoration(
													borderRadius: BorderRadius.circular(7),
													color: Colors.white,
												),
												child: Container(
													margin: EdgeInsets.all(10),
													color: Colors.white,
													child: Column(
														children: <Widget>[
															Expanded(
																	flex: 1,
																	child: Container(
																		padding: EdgeInsets.only(left: 10),
																		alignment: Alignment.centerLeft,
																		child: Text(newsModelResult[0].title,
																			overflow: TextOverflow.ellipsis,style: TextStyle(fontSize: 13, fontWeight: FontWeight.w500),),
																	)),
															Expanded(
																	flex: 2,
																	child: Container(
																		padding: EdgeInsets.only(left: 10),
																		alignment: Alignment.centerLeft,
																		child: Text(newsModelResult[0].title,
																			overflow: TextOverflow.ellipsis,
																			maxLines: 2,
																			style: TextStyle(fontSize: 12),),
																	)),
															Expanded(
																	flex: 1,
																	child: Container(
																		padding: EdgeInsets.only(left: 10),
																		alignment: Alignment.centerLeft,
																		child: Text(newsModelResult[0].date, style: TextStyle(fontSize: 13,fontWeight: FontWeight.w300),),
																	))
														],
													),
												),
											),
										)
								),
							],
						),
					),
					onTap: (){
						print(newsModelResult[0].url);
						NavigatorUtil.push(context, WebView(url: newsModelResult[0].url,));
					},
				),
				GestureDetector(
					onTap: (){
						NavigatorUtil.push(context, WebView(url: newsModelResult[1].url,));
					},
					child: Container(
						color: Colors.white,
						padding: EdgeInsets.fromLTRB(9,7,9,0),
						child: Row(
							children: <Widget>[
								Expanded(
										flex: 1,
										child: Container(
											height: MediaQuery.of(context).size.width/3,
											child: Container(
												child: ClipRRect(
														borderRadius: BorderRadius.circular(9),
														child: new CachedImage(
															imageUrl: newsModelResult[1].thumbnailPicS,
															fit: BoxFit.cover,
														)
												),
												margin: EdgeInsets.all(7),
												decoration: BoxDecoration(
													borderRadius: BorderRadius.circular(7),
												),
											),
										)
								),
								Expanded(
										flex: 2,
										child: Container(
											height: MediaQuery.of(context).size.width/3,
											child: Container(
												margin: EdgeInsets.all(7),
												decoration: BoxDecoration(
													borderRadius: BorderRadius.circular(7),
													color: Colors.white,
												),
												child: Container(
													margin: EdgeInsets.all(10),
													color: Colors.white,
													child: Column(
														children: <Widget>[
															Expanded(
																	flex: 1,
																	child: Container(
																		padding: EdgeInsets.only(left: 10),
																		alignment: Alignment.centerLeft,
																		child: Text(newsModelResult[1].title,
																			overflow: TextOverflow.ellipsis,style: TextStyle(fontSize: 13, fontWeight: FontWeight.w500),),
																	)),
															Expanded(
																	flex: 2,
																	child: Container(
																		padding: EdgeInsets.only(left: 10),
																		alignment: Alignment.centerLeft,
																		child: Text(newsModelResult[1].title,
																			overflow: TextOverflow.ellipsis,
																			maxLines: 2,
																			style: TextStyle(fontSize: 12),),
																	)),
															Expanded(
																	flex: 1,
																	child: Container(
																		padding: EdgeInsets.only(left: 10),
																		alignment: Alignment.centerLeft,
																		child: Text(newsModelResult[1].date, style: TextStyle(fontSize: 13,fontWeight: FontWeight.w300),),
																	))
														],
													),
												),
											),
										)
								),
							],
						),
					),
				),
			],
		);


  }

}